package com.re6g3y.game.entity;

import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.re6g3y.game.entity.func.Drawable;

public class TextureEntityWithBody implements Drawable{
    public Sprite sprite;
    public Body body;

    @Override
    public void draw(Batch batch){
        Vector2 pos=body.getPosition();
        sprite.setCenter(pos.x,pos.y);
        sprite.setRotation(MathUtils.radiansToDegrees*(body.getAngle() + MathUtils.PI));
        sprite.draw(batch);
//        float w=sprite.getWidth()/2;
//        float h=sprite.getHeight()/2;
//        batch.draw(sprite,pos.x-w,pos.y-h,w,h,w*2,h*2,1,1,MathUtils.radiansToDegrees*(body.getAngle() + MathUtils.PI));
    }

    public void setSpriteAndBody(Sprite sprite,Body body){
        this.sprite = sprite;
        this.body = body;
    }

    public Body getBody() {
        return body;
    }

}
